using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableAreaDao:DaoBase<TableArea>
    {
        public override void AddPrimaryIndex(TableArea model)
        {
            cachePrimary[model.areaId.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableArea.txt";
        }

        protected override TableArea ParseRowData(string[] rowData)
        {
            TableArea data = new TableArea();
			data.areaId = rowData [0];
			data.sceneName = rowData [1];

            if (string.IsNullOrEmpty(rowData[2]))
            {
                data.bornX = 0;
            }
            else
            {
                data.bornX = double.Parse(rowData[2]);
            }

            if (string.IsNullOrEmpty(rowData[3]))
            {
                data.bornY = 0;
            }
            else
            {
                data.bornY = double.Parse(rowData[3]);
            }

            if (string.IsNullOrEmpty(rowData[4]))
            {
                data.bornZ = 0;
            }
            else
            {
                data.bornZ = double.Parse(rowData[4]);
            }

            if (string.IsNullOrEmpty(rowData[5]))
            {
                data.range = 0;
            }
            else
            {
                data.range = double.Parse(rowData[5]);
            }

            if (string.IsNullOrEmpty(rowData[6]))
            {
                data.resetX = 0;
            }
            else
            {
                data.resetX = double.Parse(rowData[6]);
            }

            if (string.IsNullOrEmpty(rowData[7]))
            {
                data.resetZ = 0;
            }
            else
            {
                data.resetZ = double.Parse(rowData[7]);
            }
			data.pageName = rowData [8];
			data.pageOption = rowData [9];
			data.miniMapIcon = rowData [10];

            if (string.IsNullOrEmpty(rowData[11]))
            {
                data.canTransfer = 0;
            }
            else
            {
                data.canTransfer = int.Parse(rowData[11]);
            }

            if (string.IsNullOrEmpty(rowData[12]))
            {
                data.transferX = 0;
            }
            else
            {
                data.transferX = double.Parse(rowData[12]);
            }

            if (string.IsNullOrEmpty(rowData[13]))
            {
                data.transferY = 0;
            }
            else
            {
                data.transferY = double.Parse(rowData[13]);
            }

            if (string.IsNullOrEmpty(rowData[14]))
            {
                data.transferZ = 0;
            }
            else
            {
                data.transferZ = double.Parse(rowData[14]);
            }

            if (string.IsNullOrEmpty(rowData[15]))
            {
                data.transferAngle = 0;
            }
            else
            {
                data.transferAngle = double.Parse(rowData[15]);
            }
			data.bigMapIcon = rowData [16];
			data.npcName = rowData [17];
			data.npcDes = rowData [18];

            return data;
        }


        public override void AddOneIndex(TableArea model)
        {
            if (!cacheOneIndex.ContainsKey(model.sceneName.ToString()))
            {
                cacheOneIndex[model.sceneName.ToString()] = new List<TableArea>();
            }
            cacheOneIndex[model.sceneName.ToString()].Add(model);
        }
    

    }

}
